<?php
/* @var $this StatusController */
/* @var $model Status */

$this->breadcrumbs=array(
	Yii::t('base','Report')=>array('index'),
	Yii::t('base','Manage'),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#status-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<h1><?php echo Yii::t('base','Report')?></h1>

<?php echo Yii::t('base','<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>')?>

<?php echo CHtml::link(Yii::t('base','Advanced Search'),'#',array('class'=>'search-button')); ?>
<div class="search-form" style="display:none">
<?php $this->renderPartial('report_search',array(
	'model'=>$model,
)); ?>
</div><!-- search-form -->
<?php 
	$serch = $_REQUEST['serch'];
	$status = $_REQUEST['Status'];
	//查询报告记录
	$result = Status::model()->getReport($status[agent_id],$status[last_called_date_and_time],$status[callback_date_and_time]);
?>
<table class="responsive table table-bordered">
  <tr>
    <th><?php echo Yii::t('base','Agent');?></th>
    <th><?php echo Yii::t('base','Status');?></th>
    <th><?php echo Yii::t('base','Count');?></th>
    <th><?php echo Yii::t('base','Converting Rate');?></th>
  </tr>
  <?php 
  	for ($i=0;$i<count($result);$i++){
  ?>
  <tr>
    <td rowspan="9"><?php echo $result[$i]['agent_name']; ?></td>
  </tr>
  <?php 
  	$detials=$result[$i]['mingxi'];
  	for($j=1;$j<=count($detials);$j++){ 
?>
  <tr>
    <td><?php echo Status::model()->getStatusName($j);?></td>
    <td><?php echo $detials[$j];?></td>
    <?php if($j == 1){?>
    <td rowspan="9" style="text-align: center";><?php echo $result[$i]['rate'];?></td>
    <?php } ?>
  </tr>
  <?php } ?>
   <tr>
    <td><?php echo Yii::t('base','Total');?></td>
    <td><?php echo $result[$i]['total'];?></td>
  </tr>
 <?php } ?>
</table>


